<?php
class AuthController extends Controller
{
    public function actionIndex()
    {
        echo 'aaaaaaa';
        $auth = Yii::app()->authManager;
        
        $auth->createOperation('createPost','create a post');
        $auth->createOperation('readPost','read a post');
        $auth->createOperation('updatePost','update a post');
        $auth->createOperation('deletePost','delete a post');
        
        $bizRule='return Yii::app()->user->id==$params;';
        $task=$auth->createTask('editPost','edit a post by author himself', $bizRule);
        $task->addChild('updatePost');
        $task->addChild('deletePost');
        $task->addChild('readPost');
         
        $role=$auth->createRole('editor');
        $role->addChild('editPost');
        
        $role=$auth->createRole('admin');
        $role->addChild('editor');

        $auth->assign('editor','2');
        $auth->assign('editor','3');
        $auth->assign('admin','1');
        $auth->save();
    }
}